package com.epam.lissina.entity;

import java.util.List;

import com.epam.lissina.collector.Collect;
import com.epam.lissina.separator.TextSeparator;

public class Text {

	private List<IParagraph> paragraph;

	public List<IParagraph> getParagraph() {
		return paragraph;
	}

	public Text(String text) {
		paragraph = TextSeparator.parseText(text);
	}

	@Override
	public String toString() {
		return Collect.join(paragraph, TextSeparator.ENTER);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((paragraph == null) ? 0 : paragraph.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Text other = (Text) obj;
		if (paragraph == null) {
			if (other.paragraph != null)
				return false;
		} else if (!paragraph.equals(other.paragraph))
			return false;
		return true;
	}
}
